package com.xinqi.service.impl;

import com.xinqi.service.HelloService;
import com.xinqi.utils.pool.MyJdkPool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.Executor;

/**
 * @author xin麒
 * @date 2023/8/12 15:00
 */
@Slf4j
@Service
public class HelloServiceImpl implements HelloService {
    @Resource
    private ThreadPoolTaskExecutor xinPoolExecutor;
    @Override
    public Object processForCount(Long count) {
        xinPoolExecutor.execute(()->{
            try {
                Thread.sleep(1000 * 10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            log.debug("this is execute in pool");
        });
        return "nice";
    }
    @Autowired
    private MyJdkPool myJdkPool;
    @Override
    public Object myJdkPool(Long count) {
        myJdkPool.execute(()->{
            try {
                Thread.sleep(1000 * 10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            log.debug("this is execute in pool");
        });
        return "nice";
    }


}
